#ifndef __COMMAND_H__
#define __COMMAND_H__

#include "CommandBuffer.h"

class Command : public CommandBuffer
{
public:
	Command();
	~Command();

	typedef void (*xcommand_t) ( void );
	
	struct Func
	{
		char* name;
		xcommand_t function;
		Func* next;
	};

	struct Alias
	{
		struct Alias *next;
		char   name[MAX_ALIAS_NAME];
		char   *value;
	};

	void init();
	void add_command( char* cmd_name, xcommand_t function );
	void remove_command( char* cmd_name );
	bool exits( char* cmd_name );
	char* complete_command( char *partial );

	// arguments functions
	int argc( void );
	char* argv( int arg );
	char* args( void );
	
	void tokenize_string( char* text, bool macro );
	void execute_string( char* text );
	void execute_text( int exec_when, char* text );
	void execute( void );
	

	// script functions
	void list_f();
	void exec_f();
	void echo_f();
	void alias_f();
	void wait_f();

private:
	bool cmd_wait;
	Func* cmd_functions;
	Alias* cmd_alias;
	int cmd_argc;
	char* cmd_argv[];

	static const int MAX_ALIAS_NAME = 32;
	static const int ALIAS_LOOP_COUNT = 16;
};

#include "Command.inl"

#endif
